#!/usr/bin/python

import random, copy, sys

nbVariables = int(sys.argv[1])
outDir = sys.argv[2]
nbExemplaires = int(sys.argv[3])



for nbClauses in range(2*nbVariables, 6*nbVariables, 25):

	for i in range(0, nbExemplaires):

		outPath = outDir + "/rand3sat-%d-%d-%.2f-%d.txt" % (nbVariables, nbClauses, float(nbClauses)/float(nbVariables), i)
		out = open(outPath, "w")
		
		print nbVariables
		out.write(str(nbVariables) + "\n")
		print nbClauses
		out.write(str(nbClauses) + "\n")
	
		x = range(-nbVariables, nbVariables)
		x.remove(0)
		
		for i in range(0,nbClauses):
		
			y = copy.copy(x)	
			rnd = []
			for j in range(0, 3):
				r = random.choice(y)
				rnd.append(str(r))
				y.remove(r)
			out.write(",".join(rnd) + "\n")
		
		out.close()
